package chapter.sixth.item33;

import java.util.EnumMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;

public class Herb {
	
	public enum Type{ANNUAL,PERENNIAL,BIENNIAL}
	
	private static Herb[] garden = {};
	
	private final String name;
	private final Type type;
	
	Herb(String name,Type type){
		this.name = name;
		this.type = type;
	}

	@Override
	public String toString() {
		return name;
	}
	
	public static void main(String[] args) {
		Map<Herb.Type,Set<Herb>> herbsByType = 
				new EnumMap<Herb.Type,Set<Herb>>(Herb.Type.class);
		for(Herb.Type t:Herb.Type.values())
			herbsByType.put(t, new HashSet<Herb>());
		for(Herb h:garden)
			herbsByType.get(h.type).add(h);
		System.out.println(herbsByType);
	}
}
